<template>

	<div class="CreateUser_tab">
	     <transition enter-active-class="animated bounceInRight">
			     	<div class="CreateUser_tab_div" v-show="CreateUser_tab_div_show" >
                             <transition enter-active-class="animated bounceInLeft">
                                 
                                  <!-- 表单部分 -->
                             	 <form class="CreateUser_tab_div2" v-show="CreateUser_tab_div_show2">  
                             	        <div class="text3">
											   <div class="text2">
											 <h1>登录须知</h1>
											 <div class="carefurl">
												  <p>1.本小站目前正在装修中。</p>
											      <p>2.所有商品均未开放购买。</p>
												  <p>3.图片均来源于其他网络。</p>
												  <p>4.小站仅作学习交流使用。</p>
												  <p>5.登录视为同意以上条款。</p>
											 </div>
											
										 </div>
										 </div>
                             	       <div class="test1">
											 <h1 class="test1_h1">登录<i class="iconfont icon-shenfendengji"></i></h1>
											 <!-- 填写用户名 -->
											 <div class="Create_userName">
                                                  <span class="Create_userName_span"> UserName </span>
												  <input type="text" class="Create_userName_input" placeholder="请输入用户名" v-model="UserName" maxlength="10">
											 </div>

											 <!-- 填写密码 -->
											 <div class="Create_userName">
                                                  <span class="Create_userName_span"> PassWord </span>
												  <input type="password" class="Create_userName_input" placeholder="请输入密码" v-model="PassWord" maxlength="16">
											 </div>
											

											 <!-- 确认提交按钮 -->
											 <button class="Create_userName_submit" @click="loginTo">登录</button>
											 <!-- 跳转路径 -->
											 <div class="noRegiser">
												 还没注册？<router-link to="/CreateUser" class="noRegiser_link">前去注册</router-link>
											 </div>
										</div>
                             	 	  
                                       
                             	 </form>
                             </transition>
				  	         
				  </div>
	     </transition>
		  
	</div>
</template>

<script>
import axios from 'axios';
	export default {
		data() {
			return {
                    CreateUser_tab_div_show:false,
                    CreateUser_tab_div_show2:false,
					UserName:'',
					PassWord:'',
					loginInfo:''
					
			}
		},
		methods: {
              Createshow: function() {
              	  setTimeout(() =>{
              	  	this.CreateUser_tab_div_show= true
              	  },300)
                   }

                   ,
                    Createshow2: function() {
              	  	setTimeout( () =>{
                          this.CreateUser_tab_div_show2 =true
              	  	},1000)
              	  	
					},
					loginTo:function(){
						   if(this.UserName==''||this.PassWord == ''){
							   alert('请填写用户名或密码！');
							   
						   }else{
							    this.cheakOut();
						   }
					},
					cheakOut:function(){
						 axios.post('/login',{
							  username:this.UserName,
							  password:this.PassWord
						 }).then( (response) => {
							   this.loginInfo = response.data.msg;
							   alert(this.loginInfo);
							   console.log(response.data.info.username)
                                
                            window.localStorage.setItem('username',response.data.info.username)
                            
							//    定义登陆状态
							this.$store.commit('upDateUserName',response.data.info.username);
							this.$router.replace('/');
							  
						 })
					}
		},
		mounted:function() {
                 this.Createshow();
                 this.Createshow2();
		},
		beforeDestroy:function() {
               
		}
	}
</script>

<style>
	 .CreateUser_tab{
	 	
	 	width: 100%;
	 	height: 1000px;
	 	z-index: 100;
	 	overflow: hidden;
		background-image: url(../../../static/img/7195250.jpg);
	 	background-position: center;
		 background-size: cover;
	 
	 }
	 .CreateUser_tab_div{
	 	width: 800px;
	 	height: 600px;
	 	background-color: rgba(0,0,0,0.8);
	 	margin:50px auto;
	 	border-radius: 10px;
	 
	 }
	 .CreateUser_tab_div2{
		position: relative;
		top: 15px;
	 	height: 540px;
	 	width: 730px;
	 	padding-top:30px;
	 	margin:0 auto;
	 	background-color: #f4f1e9;
	 	text-align: center;
	 	color: #333;
	 	box-shadow: 0 0 10px #9e9e9e;
	 	border-radius: 10px;
	 	
   
	 }
	 .CreateUser_tab_div2_user{
	 	outline: none;  
		height: 30px;;	
	 	border: 1px solid #9e9e9e;
	 	background-color:#f4f1e9; 
	 	border-radius: 3px;
	 	margin-top: 40px;
	 	width: 280px;
	 }
	 .CreateUser_tab_div2_user:focus{
		 border:2px solid #1ab172
	 }
	

.test1{
		margin-top: 40px;
		 width: 400px;
		 height: 300px;
		 background-color: #f4f1e9;
		 float:right;
		 box-sizing: border-box;
		 display: flex;
		 align-items: center;
		 flex-direction: column;
		 justify-content: space-around;
	}

	.test1_h1{
		text-align: center;
		color: #333;
		text-shadow: 2px 2px 3px rgb(185, 180, 180);
		font-size: 30px;
        font-weight: bold;
		font-family: 'SimHei'
		
	}
.text3{
	width: 300px;
	 	height: 500px;
	 	border-right:1px solid #9e9e9e; 
	 	float: left;
}

	.Create_userName{
		 width: 280px;
		 height: 30px;
		 border:2px solid #9e9e9e;
		 border-radius:10px;
		 
		 position: relative;
	}
	.Create_userName_span{
		 text-align: center;
		 line-height: 30px;
		 float: left;
		 width: 90px;
		 height: 30px;
		 border-top-right-radius: 5px;
		 border-bottom-right-radius: 5px;
		  border-radius:7px;
		 background: #a2ccad;
		 color: rgb(248, 245, 245);
		 border-right: 1px solid #9e9e9e;
		 position: relative;
		 /* font-weight: bold; */
		 font-family: 'Arial','SimHei';
	}
	.Create_userName_input{
		 width: 175px;
		 height: 28px;
		 background-color: #f4f1e9;
		 border: none;
		 outline: none;
		 left: 100px;
		  position: absolute;
		  font-size: 15px;
		  font-family: 'Arial','SimHei';
	}

	.Create_userName_submit{
		 width: 280px;
		 height: 35px;
		 border: none;
		 outline: none;
		 
		 color: white;
	     background: rgb(116, 151, 161);
		 cursor: pointer;
		 border: 2px solid rgb(150, 149, 149);
		 border-radius: 5px;
		 font-size: 15px;
		font-family: 'Arial','SimHei';
		 

	}
	.Create_userName_submit:hover{
		 background: rgb(32, 204, 152);
		 border: 2px solid rgb(39, 179, 114);
	}

	 .qianbi{
		  
		 width: 120px;
		 height: 50px;
		 position: relative;
		 top: 50px;
		 left: 150px;
	 }


	 .noRegiser{
		 width: 260px;
		 height: 20px;
		 color: #333;
		 text-align: right;
		 font-size: 12px;
	 }
     .noRegiser_link{
		 color: rgb(65, 59, 59);
	 }

	 	  /*信息*/
	 .text2{
	 	width: 300px;
	 	height: 500px;
	 	border-right:1px solid #9e9e9e; 
	 	float: left;
	 }
.text2 h1{
	 text-align: center;
	 margin-top: 70px;
	 /* font-size: 20px; */
	 font-family: 'SimHei';

}
.carefurl p{
	text-align: center;
	line-height: 40px;
	font-size: 10px;
	font-family: 'SimHei'

}

.carefurl{
	 margin: 20px auto;
	 width: 80%;
	 height: 100%;

}
</style>